package com.example.webupload;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;

@SpringBootApplication
@Slf4j
public class WebUploadApplication {

//    public static void main(String[] args) {
//        SpringApplication.run(WebUploadApplication.class, args);
//    }
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(WebUploadApplication.class);
        app.addListeners(new ApplicationListener<WebServerInitializedEvent>() {
            @Override
            public void onApplicationEvent(WebServerInitializedEvent event) {
                int port = event.getWebServer().getPort();
                String contextPath = event.getApplicationContext().getApplicationName();
                contextPath = StringUtils.isEmpty(contextPath) ? "" : contextPath;
                log.info("项目启动成功！访问地址: http://localhost:" + port + contextPath+"/home.html");
            }
        });
        app.run(args);
    }
}